package com.whty.mongodemo.mongo;

import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.mongo.MongoClient;

public class MongoClientFactory {

  private final MongoClient client;

  public MongoClientFactory(Vertx vertx) {
    JsonObject config = new JsonObject()
      .put("db_name", "demo")
      .put("host", "127.0.0.1")
      .put("port", 27017)
      .put("username", "demo")
      .put("password", "demo123")
      .put("authSource", "demo")
      .put("useObjectId", true);
    this.client = MongoClient.createShared(vertx, config);
  }

  public MongoClient getInstance() {
    return this.client;
  }
}
